package com.daniel.cms.controller;

import com.daniel.cms.service.AttachServer;
import com.daniel.cms.utils.Mes;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;

/**
 * 详细说明
 *
 * @author Daniel
 * @version V1.0
 * @date 2020/4/28 09:57
 */
@Api(tags = "附件管理")
@RequestMapping("/attach")
@RestController
@Slf4j
public class AttachController {
	@Autowired
	AttachServer server;

	@ApiOperation("单文件上传")
	@ApiImplicitParams(value = {@ApiImplicitParam(name = "file", dataType = "MultipartFile", value = "文件")})
	@PostMapping("/upload")
	public Mes upload(@RequestParam("file") MultipartFile file, String key) {
		return server.upload(file, key);
	}


	public Mes multiUpload(HttpServletRequest request) {
		return server.multiUpload(request);
	}
}
